
import com.qf.RedisApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;

@SpringBootTest(classes = RedisApplication.class)
@RunWith(SpringRunner.class)
public class Demo {
    @Autowired
    private RedisTemplate redisTemplate;
    @Test
    public void test1(){
    redisTemplate.opsForValue().set("redis","hello");
        String redis =(String)redisTemplate.opsForValue().get("redis");
        System.out.println(redis);
    }

    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @Test
    public void test2(){
        stringRedisTemplate.opsForValue().set("stringRedis","hello");
        String stringRedis = stringRedisTemplate.opsForValue().get("stringRedis");
        System.out.println(stringRedis);
    }

    @Autowired
    private RedisTemplate myRedisTemplate;
    @Test
    public void test3() {
        myRedisTemplate.opsForValue().set("student","小明");
        String student =(String) myRedisTemplate.opsForValue().get("student");
        System.out.println(student);
    }

}
